package basic.class1;

public class Code01_MyQueue {
    public static void main(String[] args) {
        MyQueue q = new MyQueue(20);
        q.offer(9);
        q.offer(5);
        q.offer(2);
        q.offer(7);
        System.out.println(q.size());
        System.out.println(q.poll());
        System.out.println(q.poll());
    }

    public static class MyQueue {
        public int[] queue;
        public int l;
        public int r;

        public MyQueue(int n) {
            this.queue = new int[n];
            this.l = 0;
            this.r = 0;
        }

        public boolean isEmpty() {
            return l == r;
        }

        public void offer(int num) {
            queue[r++] = num;
        }

        public int poll() {
            return queue[l++];
        }
        public int getHead(){
            return queue[l];
        }

        public int getTail(){
            return queue[r];
        }

        public int size(){
            return r-l;
        }
    }
}
